<template>
	<view class="page">
		<wd-search v-model="phone" placeholder="用户手机号搜索"  @search="search"  @cancel="handleCancle" maxlength="18" />
		<!-- <view class="physical padding" v-for="item in content" :key="item.id" v-if="content.length > 0 " @click="showDetail(item)">
			<view class="physical_header">
				<view class="physical_header_store">
					用户编号：{{item.user_no}}
				</view>
			</view>
			<view class="physical_footer">
				<view class="physical_footer_time text-gray text-md block">
					用户手机号:{{item.mobile}}
				</view>
				<view class="physical_footer_time text-gray text-md">
					用户来源:{{item.source}}
				</view>
				<view class="physical_footer_time text-gray text-md">
					微信openid:{{item.open_id}}
				</view>
				<view class="physical_footer_time text-gray text-md">
					备注:{{item.description}}
				</view>
			</view>
		</view> -->
		<view class="nlist">
			<view class="nitem" v-for="item in content" :key="item.id" v-if="content.length > 0 " @click="showDetail(item)">
				<view class="oneitem">
					<image class="tous" src="/static/icon/icon_hy_yh.png" mode=""/>
					<text class="onename">{{item.user_no}}</text>
					<view class="zixing">自行注册账号</view>
				</view>
				<view class="twoitem">
					<view class="hengone heng">
						<view class="hitem ban">
							<text class="hleft">手机号：</text>
							<text class="hright txt">{{item.mobile||'暂无'}}</text>
						</view>
						<view class="hitem ban">
							<text class="hleft">来源：</text>
							<text class="hright txt">{{item.source}}</text>
						</view>
					</view>
					<view class="hengone heng" v-if="item.open_id">
						<view class="hitem">
							<text class="hleft">微信openid:</text>
							<text class="hright txt">{{item.open_id||'暂无'}}</text>
						</view>
					</view>
					<view class="hengone heng" v-if="item.description">
						<view class="hitem">
							<text class="hleft">备注:</text>
							<text class="hright txt">{{item.description}}</text>
						</view>
					</view>

				</view>
			</view>
		</view>
		<view class="empty" v-if="content.length == 0">
			<wd-status-tip image="content" tip="暂无会员数据" />
		</view>
		<wd-pagination v-model="pagination.page" :total="pagination.total" @change="handleChange" />
	</view>
</template>

<script setup>
	import { reactive, ref } from 'vue';
	import userApiService from "@/api/user.js"
	import {
		onLoad,
		onShow,
		onPullDownRefresh
	} from '@dcloudio/uni-app'
	const content = ref([])
	const phone = ref("")
	const pagination = reactive({
		page : 1 ,
		pagesize : 10,
		total : 0
	})



	const fetchData = () =>{
		content.value = []
		userApiService.list({
			pageNo: pagination.page,
			pageSize : pagination.pagesize
		}).then(res =>{
			uni.stopPullDownRefresh()
			content.value = res.records
			pagination.total = res.total
		})
	}

	onShow(()=>{
		fetchData()
	})


	onLoad(()=>{
		pagination.page = 1
		fetchData()
	})


	onPullDownRefresh(()=>{
		pagination.page = 1
		fetchData()
	})

	const search = () =>{
		pagination.page = 1
		content.value = []
		userApiService.list({
			pageNo: pagination.page,
			pageSize : pagination.pagesize,
			mobile : phone.value
		}).then(res =>{
			content.value = res.records
			pagination.total = res.total
		})
	}

	const handleChange = (e) =>{
		pagination.page = e.value
		fetchData()
	}

	const handleCancle = () =>{
		phone.value = ""
		pagination.page = 1
		fetchData()
	}

	const showDetail = (e) =>{
		uni.navigateTo({
			url: `/pages/user/detail?id=${e.id}`
		})
	}
</script>

<style lang="scss">
.page{
	background-color: #F3F3F3 !important;
}
.relative{
		position: relative;
	}
	.margin-top-sm{
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		background-color: #fff;
		padding: 10rpx;
		margin-top: 20rpx;
	}
	.h-full{
		min-height: 100vh;
		padding-bottom: 20rpx;
	}
	.btn{
		margin-top: 20rpx;
		width: 180rpx;
		margin-left: 80%;
	}
.empty {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}


	.add_btn {
		position: fixed;
		bottom: 40rpx;
		left: 40rpx;
		height: 100rpx;
		width: 100rpx;
		border-radius: 50%;
		box-shadow: 0 0 12px 0 rgba(#1b1b1b, .2);
		color: #fff;
	}

	.physical {
		margin:  20rpx;
		background-color: #fff;
		border-radius: 20rpx;
		box-shadow: 0 0 4px 0px #efefef;
		padding: 20rpx;
		color: #666;

		&_header {
			border-bottom: 1px solid #efefef;
			padding: 8rpx 0;
			display: flex;
			align-items: center;
			justify-content: space-between;

			&_store {
				font-size: 16px;
				font-weight: 600;
				color: #333;
			}

			&_pauseTimes {
				font-size: 12px;
				color: #f59e0b;

			}
		}

		&_body {
			padding: 40rpx 0;
			border-bottom: 1px solid #efefef;
			font-size: 12px;

			&_name {
				font-size: 16px;
				color: #f43f5e;
				font-weight: 600;
				display: inline-block;
			}
		}

		&_footer {
			font-size: 12px;

			padding-bottom: 8rpx;

			&_time {
				padding-top: 10rpx;
			}

			&_storeAddress {
				padding: 10rpx 0;
			}

			&.noborder{
				border: none;
			}
		}

		&_actions {
			padding-top: 20rpx;
			display: flex;
			align-items: center;
			justify-content: end;
			color: #00acac;
		}
	}

	.page-padding{
		padding-bottom: 80rpx;
	}

	.flex{
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}

	// 新列表样式开始
	.nlist{
		.nitem{
			margin: 20rpx;
			background-color: #fff;
			// padding: 30rpx 0 30rpx 30rpx;
			display: flex;
			flex-direction: column;
			border-radius: 20rpx;
			.oneitem{
				display: flex;
				flex-direction: row;
				align-items: center;
				margin: 20rpx 0rpx 0rpx 20rpx;
				position: relative;
				.tous{
					width: 44rpx;
					height: 44rpx;
					border-radius: 50%;
				}
				.onename{
					font-weight: bold;
					font-size: 32rpx;
					color: #1A1A1A;
					display: inline-block;
					margin-left: 10rpx;
				}
				.zixing{
					margin-left: auto;
					background: #EDF2FF;
					border-radius: 5rpx 0rpx 0rpx 5rpx;
					padding: 4rpx 20rpx;
					font-weight: 400;
					font-size: 20rpx;
					color: #6194FF;
				}
			}
			.twoitem{
				display: flex;
				flex-direction: column;
				padding: 30rpx;
				background-color: rgba(244, 246, 249, 0.8);
				border-radius: 20rpx;
				margin: 30rpx;
				.hengone{
					display: flex;
					flex-direction: column;
					margin-bottom: 20rpx;
				}
				.hengone:last-child{
					margin-bottom: 0;
				}
				.heng{
					display: flex;
					flex-direction: row;
					align-items: center;
					.hitem{
						display: flex;
						flex-direction: row;
						align-items: center;
						flex: 1;
						.hleft{
							font-weight: 400;
							font-size: 24rpx;
							color: #666666;
						}
						.hright{
							font-weight: 500;
							font-size: 24rpx;
							color: #1A1A1A;
							max-width: 73%;
							display: inline-block;
						}
					}
					.ban{
						width: 50%;
					}
					.ban:nth-child(even){
						margin-left: auto;
					}
				}
			}
		}
	}
	// 新列表样式结束
	.txt{
		overflow: hidden;  //超出隐藏
		white-space: nowrap; //不折行
		text-overflow: ellipsis; //溢出显示省略号
	}
</style>
